<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>网上祭奠</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/jquery.mCustomScrollbar.css" rel="stylesheet">
		<link href="js/JBox/jBox.css" rel="stylesheet" />
		<link href="js/JBox/plugins/Notice/jBox.Notice.css"  rel="stylesheet"/>
		<link rel="stylesheet" href="css/index.css" />
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/draggabilly.pkgd.js"></script>
    <script type="text/javascript" src="js/jquery.mCustomScrollbar.js" ></script>
    <script type="text/javascript" src="js/jquery.mCustomScrollbar.concat.min.js" ></script>
    <script type="text/javascript" src="js/JBox/jBox.js" ></script>
    <script type="text/javascript" src="js/JBox/plugins/Notice/jBox.Notice.js" ></script>
    <script type="text/javascript" src="js/jquery.easing.1.3.js" ></script>
    <script type="text/javascript" src="js/move-top.js" ></script>
    <script type="text/javascript" src="js/jquery.cookie.js" ></script>
    <script>
    	if($.cookie("JP")==null||$.cookie("JP")=="null"){
    		window.location="Login.html";
    	}
    	    	
    	$(document).ready(function(){
    		$().UItoTop({ easingType: 'easeOutQuart' });
    		initMemorialList($.getUrlParam("m"));
    	});
    	
     	function crtTimeFtt(val, row) {
	    	if (val != null) {
	            var date = new Date(val);
	            return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate();
	        }
		}   
		
		(function ($) {
                $.getUrlParam = function (name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                }
        })(jQuery);
		
    	function initMemorialList(id){
    		switch (id){
    			case "1":$(".index-title").text("祭奠名人");
    				break;
    			case "2":$(".index-title").text("祭奠先祖");
    				break;
    			case "3":$(".index-title").text("祭奠亲人");
    				break;
    			case "4":$(".index-title").text("其他祭奠");
    				break;
    			default:$(".index-title").text("祭 奠 堂");
    				break;
    		}
    		$.ajax({
	          url: "/api/Memorial/GetMemorialList?note1Type="+id,
	          type: "GET",
	          dataType: "json", 
	          success: function (data) {	
				var dataObj=eval(data);
				var html="";
				for(var i=0;i<dataObj.Data.length;i++){
					var path=dataObj.Data[i]._mphotopath;
					if(path==""||path==null)
						path="img/unknown.png";
					html+="<div class='col-lg-3 col-md-3 col-sm-6 col-xs-6 List-famous'>";
					html+="<div class='List-famous-frame'>";
					html+="<a href='Shrine.html?m="+dataObj.Data[i]._id+"'>";
					html+="<div class='List-famous-face' style='background-image: url("+path+");'></div>";
					html+="</a><div class='List-famous-baseinfo'>";
					html+="<h4>"+dataObj.Data[i]._mname+"</h4>";
					html+="<span>"+dataObj.Data[i]._msex+"</span>";
					html+="<span> "+dataObj.Data[i]._mage+"</span>";
					if(dataObj.Data[i]._note3==$.cookie("JP")){
						html+="<img class='List-edit' style='display:inline;float:right;height:24px;width:24px;cursor:pointer;' src='./img/icon_edit.png' alt='"+dataObj.Data[i]._id+"' />";
					}
					html+="<p class='List-famous-p'>"+crtTimeFtt(dataObj.Data[i]._birthdate)+"</p>";
					html+="<p class='List-famous-p'>"+crtTimeFtt(dataObj.Data[i]._deathdate)+"</p>";
					html+="</div><br style='clear: both;'/>";
					html+="<p class='List-famous-section'>"+dataObj.Data[i]._mresume+"</p>";
					html+="</div></div>";
				}	
				$(".row").html(html);		
				$(".List-edit").click(function(){
					window.location="EditBase.html?m="+$(this).attr("alt")+"&f="+$.getUrlParam("m");
				});
           },
           error:function(XMLHttpRequest,textStatus,errorThrown)
           {
           	console.log(errorThrown);
           }
         });
    	}
    </script>
	</head>
	<body class="index-worship">
		<div class="index-top">
			<a href="Index.html"><div class="index-shrineback"> </div></a>
			<span class="index-title">祭 奠 堂</span>
			<a href="NewShrine.html"><div class="index-addshrine"> </div></a>
		</div>
		<div class="index-worship-head">
			<span>祭奠名人</span>
		</div>
		<div class="index-search">
			<div>
			<input  type="text" placeholder="输入搜索信息"/>
			<button></button>
			</div>
		</div>
			<div class="row"></div>
			<div class="toTop" href="#to-top" id="toTop">
				返回<br/>顶部
			</div>
	</body>
</html>
